Introduce is_running_on_xen() to test whether we are running on Xen before
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 19 May 2006 14:35:19 +0000 (15:35 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 19 May 2006 14:35:19 +0000 (15:35 +0100)
initialising a Xen-specific driver or subsystem.

For ia64:
 * Call xen_init in setup_arch.
 * Remove xen_ksyms.c

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
21 files changed:
linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c
linux-2.6-xen-sparse/arch/ia64/kernel/setup.c
linux-2.6-xen-sparse/arch/ia64/xen/Makefile
linux-2.6-xen-sparse/arch/ia64/xen/drivers/xenia64_init.c
linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c [deleted file]
linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
linux-2.6-xen-sparse/drivers/xen/console/console.c
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
linux-2.6-xen-sparse/drivers/xen/core/hypervisor_sysfs.c
linux-2.6-xen-sparse/drivers/xen/core/xen_sysfs.c
linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h
linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h

index 936dbb7eff92532c619b4c3ec8a0fb76b87ddede..e65ebf681faa9afbac3c145efac131babb8c8521 100644 (file)
@@ -191,6 +191,7 @@ swiotlb_init(void)
        if (swiotlb_force == 1) {
                swiotlb = 1;
        } else if ((swiotlb_force != -1) &&
+                  is_running_on_xen() &&
                   (xen_start_info->flags & SIF_INITDOMAIN)) {
                /* Domain 0 always has a swiotlb. */
                ram_end = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
index a6ac8f6b84bc048381b084e8ac617a9097877042..6f30d486082be848551db201f810237676043af0 100644 (file)
@@ -514,6 +514,9 @@ setup_arch (char **cmdline_p)
 #ifdef CONFIG_XEN
        if (running_on_xen) {
                extern shared_info_t *HYPERVISOR_shared_info;
+               extern int xen_init (void);
+
+               xen_init ();
 
                /* xen_start_info isn't setup yet, get the flags manually */
                if (HYPERVISOR_shared_info->arch.flags & SIF_INITDOMAIN) {
index 833680cccf2fe876d3f3d46d128378f631ff7a68..5794a4136c91f9d0701258db5de081547c3d2570 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for Xen components
 #
 
-obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o xen_ksyms.o
+obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o
 
 obj-$(CONFIG_XEN_IA64_DOM0_VP) += hypervisor.o pci-dma-xen.o
-pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
\ No newline at end of file
+pci-dma-xen-$(CONFIG_XEN_IA64_DOM0_VP) := ../../i386/kernel/pci-dma-xen.o
index 58403804fbf59d2ed54096c09680c459998f12d4..54517f8fe6273a5b25c48d016f248986aab52eb3 100644 (file)
 shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)XSI_BASE;
 EXPORT_SYMBOL(HYPERVISOR_shared_info);
 
-static int initialized;
 start_info_t *xen_start_info;
 
+int running_on_xen;
+EXPORT_SYMBOL(running_on_xen);
+
 int xen_init(void)
 {
+       static int initialized;
        shared_info_t *s = HYPERVISOR_shared_info;
 
        if (initialized)
                return running_on_xen ? 0 : -1;
 
-       if (!running_on_xen)
+       if (!is_running_on_xen())
                return -1;
 
        xen_start_info = __va(s->arch.start_info_pfn << PAGE_SHIFT);
diff --git a/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c b/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c
deleted file mode 100644 (file)
index 83cff0b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Architecture-specific kernel symbols
- *
- * Don't put any exports here unless it's defined in an assembler file.
- * All other exports should be put directly after the definition.
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-
-extern int is_running_on_xen(void);
-EXPORT_SYMBOL(is_running_on_xen);
index c611974d78d3be638b37d6fa827ad1425e21c3cc..5c41876bc5c846e9e1d5172c7f811f43545aaeae 100644 (file)
@@ -8,12 +8,6 @@
 #include <asm/processor.h>
 #include <asm/asmmacro.h>
 
-       .data
-       .align 8
-       .globl running_on_xen
-running_on_xen:
-       data4 0
-
 #define isBP   p3      // are we the Bootstrap Processor?
 
        .text
@@ -27,9 +21,3 @@ GLOBAL_ENTRY(early_xen_setup)
 (p7)   mov cr.iva=r10
        br.ret.sptk.many rp;;
 END(early_xen_setup)
-
-GLOBAL_ENTRY(is_running_on_xen)
-       movl r9=running_on_xen;;
-       ld4 r8=[r9]
-       br.ret.sptk.many rp;;
-END(is_running_on_xen)
index 13b5c95a6fef340b29dc7a9fdf81763e9a733640..a0ea8d11603858b88eabeed00ba1479d08026cef 100644 (file)
@@ -468,8 +468,8 @@ static int __init balloon_init(void)
 
        IPRINTK("Initialising balloon driver.\n");
 
-       if (xen_init() < 0)
-               return -1;
+       if (!is_running_on_xen())
+               return -ENODEV;
 
        current_pages = min(xen_start_info->nr_pages, max_pfn);
        totalram_pages = current_pages;
index addc9369a2fd96e46b330972194ad6a1fcfe3509..39daafe43cb57284af23f553cc1ad16b9a6cd110 100644 (file)
@@ -526,7 +526,7 @@ static int __init blkif_init(void)
        struct page *page;
        int i;
 
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
index 57b5c27592b231aea9306dc1853ca38f9bb6a85e..f8e45efa47788131510a0e47818c3ec327f40d2b 100644 (file)
@@ -792,7 +792,7 @@ static struct xenbus_driver blkfront = {
 
 static int __init xlblk_init(void)
 {
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        return xenbus_register_frontend(&blkfront);
index b5438f20c9a56663ca23c7e0fe2c6babc8bd3879..de0a1e345797d1a1ba6ac06149788ec22b8b6219 100644 (file)
@@ -183,7 +183,7 @@ static struct console kcons_info = {
 #define __RETCODE 0
 static int __init xen_console_init(void)
 {
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return __RETCODE;
 
        if (xen_start_info->flags & SIF_INITDOMAIN) {
@@ -566,7 +566,7 @@ static int __init xencons_init(void)
 {
        int rc;
 
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        if (xc_mode == XC_OFF)
index 735507396673249cb835f3363c228c65700ae0ce..0b288e61b2e982d14ffce5e5966d9660f706801a 100644 (file)
@@ -443,7 +443,7 @@ gnttab_init(void)
 {
        int i;
 
-       if (xen_init() < 0)
+       if (!is_running_on_xen())
                return -ENODEV;
 
        if (gnttab_resume() < 0)
index f9639028d292ce2ac1c2f9fcf9d0fbf489ca10a6..42ee6a8148fe616d6735d2b6e41845f7ffe35c05 100644 (file)
@@ -49,6 +49,9 @@ static struct kobj_type hyp_sysfs_kobj_type = {
 
 static int __init hypervisor_subsys_init(void)
 {
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        hypervisor_subsys.kset.kobj.ktype = &hyp_sysfs_kobj_type;
        return subsystem_register(&hypervisor_subsys);
 }
index e26ab7f0037fe5fbfa01eccf81b6751260721e5c..abe52d5a8b405ad4676c64d6cf405e9f75f8b91a 100644 (file)
@@ -276,7 +276,12 @@ static void xen_properties_destroy(void)
 
 static int __init hyper_sysfs_init(void)
 {
-       int ret = xen_sysfs_type_init();
+       int ret;
+
+       if (!is_running_on_xen())
+               return -ENODEV;
+
+       ret = xen_sysfs_type_init();
        if (ret)
                goto out;
        ret = xen_sysfs_version_init();
index 2c8623392ea2f6dd3e3b0dca851a8f66c58ce70f..9e8503f34b824202529ae55eb71a8a31726a8bb2 100644 (file)
@@ -429,6 +429,9 @@ static int __init evtchn_init(void)
 {
        int err;
 
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        spin_lock_init(&port_user_lock);
        memset(port_user, 0, sizeof(port_user));
 
index 3aee0a1d81d66ca17ffaf979e2851ef4d3062812..a6f5080bfd26ae690f9733f4ebfeebc131e4fcb2 100644 (file)
@@ -810,6 +810,9 @@ static int __init netback_init(void)
        int i;
        struct page *page;
 
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        /* We can increase reservation by this much in net_rx_action(). */
        balloon_update_driver_allowance(NET_RX_RING_SIZE);
 
index 9c0df415c2001fc7746d96516dd16ffce5a4f457..2fdc373dcd1a34d0088407660ef28cdafdae81a0 100644 (file)
@@ -1454,6 +1454,9 @@ static struct notifier_block notifier_inetdev = {
 
 static int __init netif_init(void)
 {
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        if (xen_start_info->flags & SIF_INITDOMAIN)
                return 0;
 
index 477c7a1f3aba87367fb5d98f723ade28b5d20c3d..0c8b44934810274e0223b56cd8f346ac2869cbac 100644 (file)
@@ -271,6 +271,9 @@ static int capabilities_read(char *page, char **start, off_t off,
 
 static int __init privcmd_init(void)
 {
+       if (!is_running_on_xen())
+               return -ENODEV;
+
        /* Set of hypercalls that privileged applications may execute. */
        set_bit(__HYPERVISOR_acm_op,           hypercall_permission_map);
        set_bit(__HYPERVISOR_dom0_op,          hypercall_permission_map);
index 67134b060a6415f3b9fd4e1b4f4a3b810eb51918..f410395d197a094be2eb9b6846c1d88193b7bdec 100644 (file)
@@ -966,10 +966,8 @@ static int __init xenbus_probe_init(void)
 
        DPRINTK("");
 
-       if (xen_init() < 0) {
-               DPRINTK("failed");
+       if (!is_running_on_xen())
                return -ENODEV;
-       }
 
        /* Register ourselves with the kernel bus subsystem */
        bus_register(&xenbus_frontend.bus);
@@ -1069,10 +1067,8 @@ static int __init wait_for_devices(void)
 {
        unsigned long timeout = jiffies + 10*HZ;
 
-       if (xen_init() < 0) {
-               DPRINTK("failed");
+       if (!is_running_on_xen())
                return -ENODEV;
-       }
 
        while (time_before(jiffies, timeout)) {
                if (all_devices_ready())
index e4ec1309d39ed48f3bb1fed1c76e4f6346653fec..29b7b26807096b20e976510ab35035b2d1787506 100644 (file)
@@ -118,7 +118,7 @@ u64 jiffies_to_st(unsigned long jiffies);
 #define MULTI_UVMDOMID_INDEX 4
 #endif
 
-#define xen_init()     (0)
+#define is_running_on_xen() 1
 
 static inline int
 HYPERVISOR_yield(
index 208c392fccdd06d638673565d186d5a172264cd6..281b1af3cb1a2ce0175093cb2baf88d9743f1ab3 100644 (file)
@@ -53,7 +53,7 @@ extern start_info_t *xen_start_info;
 
 void force_evtchn_callback(void);
 
-int xen_init(void);
+#define is_running_on_xen() running_on_xen
 
 /* Turn jiffies into Xen system time. XXX Implement me. */
 #define jiffies_to_st(j)       0
@@ -147,7 +147,7 @@ xen_create_contiguous_region(unsigned long vstart,
                              unsigned int order, unsigned int address_bits)
 {
        int ret = 0;
-       if (running_on_xen) {
+       if (is_running_on_xen()) {
                ret = __xen_create_contiguous_region(vstart, order,
                                                     address_bits);
        }
@@ -158,7 +158,7 @@ void __xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
 static inline void
 xen_destroy_contiguous_region(unsigned long vstart, unsigned int order)
 {
-       if (running_on_xen)
+       if (is_running_on_xen())
                __xen_destroy_contiguous_region(vstart, order);
 }
 #else
index db737b394060120e77c94dcfcb1dce1a95282731..29ff8820dd744ff116af2daf14502803ed97a05e 100644 (file)
 #endif
 
 #ifndef __ASSEMBLY__
-#ifdef MODULE
-extern int is_running_on_xen(void);
-#define running_on_xen (is_running_on_xen())
-#else
 extern int running_on_xen;
-#endif
 
 #define        XEN_HYPER_SSM_I                 asm("break 0x7");
 #define        XEN_HYPER_GET_IVR               asm("break 0x8");